$(function () {
    //gotop();
    var bt = $('#toolBackTop');
    var sw = $(document.body)[0].clientWidth;

    var limitsw = (sw - 840) / 2 - 80;  //距离右侧距离
    if (limitsw > 0) {
        limitsw = parseInt(limitsw);
        bt.css("right", limitsw / 8);
    }

    $(window).scroll(function () {
        var st = $(window).scrollTop();
        if (st > 30) {
            bt.show();
        } else {
            bt.hide();
        }
    });
});

function gotop() {
    $('html,body').animate({scrollTop: '0px'}, 'slow');
}

$(document).ready(function () {
    $('.tab_buttons li').mousemove(function () {
        $(this).addClass('tab_current').siblings().removeClass('tab_current');
        $('.tab_text>div:eq(' + $(this).index() + ')').show().siblings().hide();
    });

});


function homepage() {
    window.location.href = "index";
}
function category(id) {
    var url;
    if (id == undefined) {
        url = "category";
    } else {
        url = "category?id=" + id;
    }
    window.location.href = url;
}
function archive(date) {
    var url;
    if (date == undefined) {
        url = "archive";
    } else {
        url = "archive?date=" + date;
    }
    window.location.href = url;
}

function me() {
    var url = "me";
    window.location.href = url;
}

function whisper() {
    var url = "whisper";
    window.location.href = url;
}
function album() {
    var url = "album";
    window.location.href = url;
}
function albumImg(id){
    var url = "albumimg?id="+id;
    window.location.href = url;
}

function link() {
    var url = "link";
    window.location.href = url;
}

function book(){
    var url = "book";
    window.location.href = url;
}
function articalDetail(id) {
    var url = "view?id=" + id;
    window.location.href = url;
}

function tool(){
    var url = "tool";
    window.location.href = url;
}

function tags(){
    var url = "tags";
    window.location.href = url;
}
function tag(tagName){
    var url = "artical?tag="+tagName;
    window.location.href=url;
}
function readbook(id) {
    var url = "read?id=" + id;
    window.open(url);
}

function topic(id) {
    var url;
    if (id == undefined) {
        url = "topic";
    } else {
        url = "topic?id=" + id;
    }
    window.location.href = url;
}

function message(id){
    var url;
    if(id == undefined){
        url = "message";
    }else{
        url = "message?id=" + id;
    }
    window.location.href = url;
}

$(function () {
    var musicWin;
    $('#music').on('click', function(){
        if (!musicWin || musicWin.closed) {
            var url = "music";
            window.open(url, "_musicWin");
        }
    });

    $('#manage').on('click',function(){
        window.location.href = "manage/index";
    })
});
var professWin;
function profess() {
    if (!professWin || professWin.closed) {
        var url = "profess";
        window.open(url, "_professWin");
    }
}
function register(){
    window.location.href = "register"
}

$(function () {
    $("[data-toggle='weixinpopvoer']").popover({
        trigger: 'manual',
        placement: 'right', //placement of the popover. also can use top, bottom, left or right
        html: 'true', //needed to show html of course
        content: content2(), //this is the content of the html box. add the image here or anything you want really.
        animation: false
    }).on("mouseenter", function () {
        var _this = this;
        $(this).popover("show");
        $(this).siblings(".popover").on("mouseleave", function () {
            $(_this).popover('hide');
        });
    }).on("mouseleave", function () {
        var _this = this;
        setTimeout(function () {
            if (!$(".popover:hover").length) {
                $(_this).popover("hide")
            }
        }, 100);
    });
});

function content2() {
    var data = $("<div>" +
        "<div>" +
        "<img src='images/wx.jpg' style='width: 115px; height: 115px;margin: -10px;'>" +
        "</div>");
    return data;
}


layui.use('layer', function(){
    var layer = layui.layer;

    $('#skin').on('click', function(){
        layer.open({
            title: '皮肤选择',
            type: 1,
            area: ['600px', '360px'],
            shadeClose: true, //点击遮罩关闭
            content: '\<\div align="center" style="padding:20px;">自定义内容\<\/div>',
            btn: ['默认颜色', '冷酷黑', '绚烂紫']
            ,yes: function(index, layero){
                //按钮【按钮一】的回调
                alert("默认颜色");
            }
            ,btn2: function(index, layero){
                //按钮【按钮二】的回调
                alert("冷酷黑");
                return false;// 开启该代码可禁止点击该按钮关闭
            }
            ,btn3: function(index, layero){
                //按钮【按钮三】的回调
                alert("绚烂紫");
                //return false 开启该代码可禁止点击该按钮关闭
            }
        });
    });
});



